<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="../../css/allApp.css" />
		<link rel="stylesheet" href="css/css.css" />
		<style>
			.beizhu {
				display: none;
			}
			
			.mui-right-title {
				color: #007AFF;
			}
			
			.sp-title.p10 {
				padding: 0 10px;
			}
			
			.sp-title.p10 span {
				font-size: 15px;
			}
			
			.sp-group {
				text-align: center;
				display: inline-block;
			}
			
			.mui-popover-add {
				top: 180px!important;
				width: 90%;
				margin-left: 5%;
				background: #ffffff;
				padding-top: 10px;
			}
			
			input.w50 {
				width: 50%;
			}
			
			#lineChart {
				height: 280px;
				background: #fff;
				padding: 5px 10px;
				/*margin-top: 10px;*/
			}
			
			.photo {
				display: block;
			}
			
			.yichang-text .img-up {
				width: 100%;
			}
			
			.img {
				width: 30%;
				margin-top: 10px;
				border-radius: 6px;
				padding: 16px 10px;
				border-radius: 6px;
				text-align: center;
				border: 1px dotted #b8bdc3;
				color: #999;
				background: #f5f5f5;
			}
			
			.yichang-text .img-up {
				padding: 8px;
				overflow: hidden;
				margin: 0;
			}
			
			.photo {
				position: relative;
				width: 30%;
				height: 90px;
				margin-top: 10px;
				border-radius: 6px;
				margin-right: 8px;
				overflow: hidden;
			}
			
			.photo:nth-child(3) {
				margin-right: 0;
			}
			
			.photo img {
				width: 100%;
			}
			
			.photo span {
				position: absolute;
				top: 0;
				right: 0;
				background: rgba(0, 0, 0, .2);
				color: #fff;
				border-radius: 4px;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">特殊巡检项填写</h1>
		</header>
		<div class="mui-content">
			<div class="fj-content" id="rate_id">
				<div class="mui-row fj-row" id="shebei">
					<span class="mui-pull-left">设备信息</span>
					<a class="mui-icon mui-icon-arrowright mui-icon-right-nav mui-pull-right"></a>

				</div>
				<div class="mui-row fj-row hide" id="shebeimc">
					<span class="mui-pull-left"></span>
				</div>
				<div class="mui-row fj-row hide" id="shebeibh">
					<span class="mui-pull-left"></span>
				</div>
			</div>
			<div class="xj-content">
				<div class="H-10"></div>
				<div class="mui-card">
					<!--内容区-->
					<div class="mui-card-content" style="border: 0;">
						<p class="biaozhun"></p>
						<div class="yichang-text">
							<div class="textarea">

								<textarea placeholder="填写备注" id="remark"></textarea>
							</div>
							<div class="mui-row img-up">
								<!--<div class="photo mui-pull-left"data-id=""><img src="../../img/camera@3x.png"/><span class="mui-icon mui-icon-closeempty delete_"></span></div>-->
								<div class="img mui-pull-left" id="camera">
									<span class="mui-icon mui-icon-image"></span>
									<p>拍照上传</p>
								</div>
							</div>
						</div>

					</div>
				</div>
			</div>
			<div class="btn">
				<button type="button" class="mui-btn mui-btn-primary mui-col-xs-12 " id="sure">提交</button>
			</div>
		</div>

		<script src="../../js/mui.min.js"></script>
		<script src="../../js/jquery-3.1.1.js"></script>
		<script type="text/javascript" src="../../js/mkeyplus.base.xunjian.js"></script>
		<script type="text/javascript" src="../../js/common.js"></script>
		<script src="../../js/workTicket_up.js"></script>
		<script src="../../js/uuid.js"></script>
		<script src="./js/websql.js"></script>
		<script src="./js/mui.previewimage.js"></script>
		<script src="./js/mui.zoom.js"></script>
		<script type="text/javascript" src="../index1/js/echarts.js"></script>
		<script type="text/javascript">
			mui.init();
			mui.previewImage();
			var userxjId = "";
			var wind = "";
			var sbid = "";
			var opener = "";
			var rateid;
			var rate;
			var scancode;
			var smTime;
			var param = {};
			mui.plusReady(function() {
				var self = plus.webview.currentWebview();
				rate = self.index;
				scancode = self.scancode;
				smTime = self.smTime;
				opener = self.opener();
			})
			//打开设备信息页面
			document.querySelector('#shebei').addEventListener('tap', function() {
				mui.openWindow({
					id: "shebeixinxi.html",
					url: "shebeixinxi.html",
					waiting: {
						autoShow: false, //自动显示等待框，默认为true
					},
					extras: {
						scancode: scancode,
						index: rate,
					}
				});
			});

			document.querySelector('#sure').addEventListener('tap', function() {
				mui.baseApp.httpRequst('/api/v2/sbxj/findSbInfo', {
						scancode: scancode
					},
					function(res) {
						console.log("特殊巡检项" + JSON.stringify(res));
						var data = res.data;
						console.log("巡检项1111" + JSON.stringify(data));
						if(res.status == 200) {
							wind = data.wind;
							sbid = data.id;
						} else if(res.status == 400) {
							mui.toast(data.message)
						} else if(res.status == 409) {
							mui.toast(data.message)
						}
					}
				);
				console.log("Image====" + localStorage.getItem('Image'));
				if (plus.networkinfo.getCurrentType()  ==  plus.networkinfo.CONNECTION_NONE)  {

				} else {
					var btnArr = ['确认', '取消'];
					mui.confirm('确认提交吗?', '操作提示', btnArr, function(e) {
						if(e.index == 0) {
							if($('.photo').length != undefined) {
								console.log('Image1已经接收到');
								$.each($('.photo'), function(i, v) {
									param['img[' + i + '].attach'] = $(v).attr('data-id');
								});
							}
							param['wind'] = wind;
							param['memberId'] = localStorage.getItem('userid');
							param['sbid'] = sbid;
							param['remark'] = $("#remark").val();
							plus.nativeUI.showWaiting('提交中...');
							mui.baseApp.httpRequst('/api/v2/sbxj/SubmitSpecialXj', param,
								/*{
									wind: wind,
									memberId: localStorage.getItem('userid'),
									sbid: sbid,
									img:JSON.stringify(imgSrc),
									remark: $("#remark").val()
								}*/
								function(data) {
									plus.nativeUI.closeWaiting();
									console.log('111111' + JSON.stringify(data));
									if(data.status == "200") {
										mui.toast(data.message);
										mui.openWindow({
											url: 'jiankong.html',
											id: 'jiankong.html',
										});
										plus.webview.currentWebview().close();
										opener.close('none');
										//										opener.evalJS('close()');
									} else if(data.status == "400") {
										mui.toast(data.message);
									} else if(data.status == "409") {
										mui.toast(data.message);
									}

								})
						}

					});
				}

			});
		</script>
	</body>

</html>